package org.qingke.mail.sso.controller;

import org.qingke.mail.common.Response;
import org.qingke.mail.common.SSORequest;
import org.qingke.mail.sso.service.SSOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * SSO控制器
 * @author JAVA
 *
 */
@Controller
@RequestMapping("/sso/user")
public class SSOController {
	
	@Autowired
	private SSOService ssoService;
	
	@RequestMapping("/check/{propertyName}/{propertyValue}")
	@ResponseBody
	public Response check(@PathVariable String propertyName,@PathVariable String propertyValue){
		return ssoService.check(propertyName, propertyValue);
	}
	
	@RequestMapping(value="/register", method={RequestMethod.POST})
	@ResponseBody
	public Response register(SSORequest userRequest){
		return ssoService.register(userRequest);
	}
	
	@RequestMapping(value="/login", method={RequestMethod.POST})
	@ResponseBody
	public Response login(SSORequest userRequest){
		return ssoService.Login(userRequest);
	}
	/**
	 * 权限认证
	 * @param userRequest
	 * @return
	 */
	@RequestMapping(value="/authenication", method={RequestMethod.POST})
	@ResponseBody
	public Response authenication(SSORequest userRequest){
		return ssoService.authenication(userRequest);
	}
	
}
